package com.bbm.bbmanage.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bbm.bbmanage.entity.HouseOrder;
import com.bbm.bbmanage.entity.vo.ResponseResult;
import com.bbm.bbmanage.service.HouseOrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * (HouseOrder)表控制层
 *
 * @author lionkliu
 * @since 2024-04-17 14:14:44
 */
@RestController
@RequestMapping("houseOrder")
public class HouseOrderController {

    @Resource
    private HouseOrderService houseOrderService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return houseOrderService.selectPage(pageNum, pageSize);
    }

    @GetMapping("/search")
    public ResponseResult search(
            @RequestParam("userId") Integer userId,
            @RequestParam("pageNum") Integer pageNum,
            @RequestParam("pageSize") Integer pageSize) {
        return houseOrderService.search(pageNum, pageSize, userId);
    }

    @GetMapping("/list")
    public ResponseResult list() {
        return ResponseResult.okResult(houseOrderService.list());
    }

    @GetMapping("{id}")
    public ResponseResult selectOne(@PathVariable Integer id) {
        return houseOrderService.selectOne(id);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody HouseOrder houseOrder) {
        return houseOrderService.insertOne(houseOrder);
    }

    @PutMapping
    public ResponseResult update(@RequestBody HouseOrder houseOrder) {
        return houseOrderService.updateOne(houseOrder);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return houseOrderService.deleteById(id);
    }

}
